package com.vhall.autotest.api_test.service;

import java.util.HashMap;
import java.util.Map;

import org.junit.Assert;

import com.alibaba.fastjson.JSONObject;
import com.vhall.autotest.api_test.common.Constant;
import com.vhall.autotest.api_test.common.HttpUtil;
import com.vhall.autotest.api_test.service.code.ICode;
import com.vhall.autotest.api_test.service.code.IWebinarCode;

public class Webinar implements IWebinarCode{

	private static final String createUrl = Constant.apiDomain + "/api/vhallapi/v2/webinar/create";
	private static final String updateUrl = Constant.apiDomain + "/api/vhallapi/v2/webinar/update";
	private static final String startUrl = Constant.apiDomain + "/api/vhallapi/v2/webinar/start";
	private static final String deleteUrl = Constant.apiDomain + "/api/vhallapi/v2/webinar/delete";
	private static final String listUrl = Constant.apiDomain + "/api/vhallapi/v2/webinar/list";
	private static final String fetchUrl = Constant.apiDomain + "/api/vhallapi/v2/webinar/fetch";
	private static final String stateUrl = Constant.apiDomain + "/api/vhallapi/v2/webinar/state";
	private static final String stopUrl = Constant.apiDomain + "/api/vhallapi/v2/webinar/stop";
	private static final String currentOnlineNumberUrl = Constant.apiDomain + "/api/vhallapi/v2/webinar/current-online-number";
	private static final String guestUrl = Constant.apiDomain + "/api/vhallapi/v2/guest/url";
	private static final String reportTrackUrl = Constant.apiDomain + "/api/vhallapi/v2/report/track";
	private static final String getOnlineLimitUrl = Constant.apiDomain + "/api/vhallapi/v2/webinar/get-online-limit";
	private static final String addWhiteUrl = Constant.apiDomain + "/api/vhallapi/v2/attendee/add-whitelist";
	private static final String chatHistoryUrl = Constant.apiDomain + "/api/vhallapi/v2/chat/history";
	private static final String guestCancelUrl = Constant.apiDomain + "/api/vhallapi/v2/guest/cancel-url";
	private static final String chatFilterUrl = Constant.apiDomain + "/api/vhallapi/v2/chat/filter";
	private static final String onlineUrl = Constant.apiDomain + "/api/vhallapi/v2/report/online";
	private static final String activeimageUrl = Constant.apiDomain + "/api/vhallapi/v2/webinar/activeimage";
	private static final String attendeeRecordsUrl = Constant.apiDomain + "/api/vhallapi/v2/report/attendee-records";
	
	
	public static Map<String, String> create_success(String subject, String start_time, String exist_3rd_auth,
			String auth_url, String failure_url, String introduction, String layout, String type, String auto_record,
			String is_chat, String host, String buffer) {
		Map<String, String> param = new HashMap<String, String>();
		param.put("subject", subject);
		param.put("start_time", start_time);
		param.put("exist_3rd_auth", exist_3rd_auth);
		param.put("auth_url", auth_url);
		param.put("failure_url", failure_url);
		param.put("introduction", introduction);
		param.put("layout", layout);
		param.put("type", type);
		param.put("auto_record", auto_record);
		param.put("is_chat", is_chat);
		param.put("host", host);
		param.put("buffer", buffer);
		Account.setAccount(param);
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(createUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		System.out.println("statusCode:" + statusCode);
		System.out.println("resultText:" + resultText);
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}

	public static void create_failCheck(String subject, String start_time, String exist_3rd_auth, String auth_url,
			String failure_url, String introduction, String layout, String type, String auto_record, String is_chat,
			String host, String buffer, int assertStatusCode, int assertCode) {
		Map<String, String> param = new HashMap<String, String>();
		if(subject != null){
			param.put("subject", subject);
		}
		
		if(start_time != null){
			param.put("start_time", start_time);
		}
		
		param.put("exist_3rd_auth", exist_3rd_auth);
		if(auth_url != null){
			param.put("auth_url", auth_url);
		}
	
		param.put("failure_url", failure_url);
		param.put("introduction", introduction);
		if(layout != null){
			param.put("layout", layout);
		}
		param.put("type", type);
		param.put("auto_record", auto_record);
		param.put("is_chat", is_chat);
		param.put("host", host);
		param.put("buffer", buffer);
		Account.setAccount(param);
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(createUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		System.out.println(resultText);
		Assert.assertTrue(String.valueOf(assertStatusCode).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("result obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(assertCode)));

	}

	public static Map<String, String> update_success(String webinar_id, String subject, String start_time, String exist_3rd_auth,
			String auth_url, String introduction, String layout, String type, String auto_record,
			String is_chat, String host, String buffer) {
		Map<String, String> param = new HashMap<String, String>();
		param.put("webinar_id", webinar_id);
		param.put("subject", subject);
		param.put("start_time", start_time);
		param.put("exist_3rd_auth", exist_3rd_auth);
		param.put("auth_url", auth_url);
		param.put("introduction", introduction);
		param.put("layout", layout);
		param.put("type", type);
		param.put("auto_record", auto_record);
		param.put("is_chat", is_chat);
		param.put("host", host);
		param.put("buffer", buffer);
		Account.setAccount(param);
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(updateUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		System.out.println("statusCode:" + statusCode);
		System.out.println("resultText:" + resultText);
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}

	public static void update_failCheck(String webinar_id, String subject, String start_time, String exist_3rd_auth, String auth_url,
			String introduction, String layout, String type, String auto_record, String is_chat,
			String host, String buffer, String is_open, int assertStatusCode, int assertCode) {
		Map<String, String> param = new HashMap<String, String>();
		param.put("webinar_id", webinar_id);
		if(subject != null){
			param.put("subject", subject);
		}
		
		if(start_time != null){
			param.put("start_time", start_time);
		}
		
		param.put("exist_3rd_auth", exist_3rd_auth);
		if(auth_url != null){
			param.put("auth_url", auth_url);
		}
	
		
		param.put("introduction", introduction);
		if(layout != null){
			param.put("layout", layout);
		}
		if(is_open != null){
			param.put("is_open", is_open);
		}
		param.put("type", type);
		param.put("auto_record", auto_record);
		param.put("is_chat", is_chat);
		param.put("host", host);
		param.put("buffer", buffer);
		Account.setAccount(param);
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(updateUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(assertStatusCode).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("result obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(assertCode)));

	}

	public static void start_success(String webinar_id) {
		Map<String, String> param = new HashMap<String, String>();
		param.put("webinar_id", webinar_id);
		Account.setAccount(param);
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(startUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println(resultText);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
	}

	public static void start_failCheck(String webinar_id, int assertStatusCode, int assertCode) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if (webinar_id != null) {
			param.put("webinar_id", webinar_id);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(startUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(assertStatusCode).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println(obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(assertCode)));

	}

	public static Map<String, String> delete_success(String webinar_id) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		param.put("webinar_id", webinar_id);
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(deleteUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		System.out.println("delete statusCode:" + statusCode + " resultText:" + resultText);
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}

	public static void delete_failCheck(String webinar_id, int assertStatusCode, int assertCode) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(deleteUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(assertStatusCode).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(assertCode)));

	}

	public static Map<String, String> list_success(String type, String pos, String limit, String status) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if (type != null) {
			param.put("type", type);
		}
		if (pos != null) {
			param.put("pos", pos);
		}
		if (limit != null) {
			param.put("limit", limit);
		}
		if (status != null) {
			param.put("status", status);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(listUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		System.out.println(statusCode);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("list_success statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}

	public static Map<String, String> fetch_success(String webinar_id, String fields) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		param.put("webinar_id", webinar_id);
		param.put("fields", fields);
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(fetchUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("fetch_success statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}

	public static Map<String, String> state_success(String webinar_id) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(stateUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("state_success obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}
	
	public static Map<String, String> stop_success(String webinar_id) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(stopUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("stop_success obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}
	
	public static Map<String, String> stop_failCheck(String webinar_id, int assertStatusCode, int assertCode) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(stopUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(assertStatusCode).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("stop_failCheck obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(assertCode)));
		return result;
	}
	
	public static Map<String, String> currentOnlineNumber_success(String webinar_id) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		param.put("webinar_id", webinar_id);
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(currentOnlineNumberUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("currentOnlineNumber_success statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}
	
	
	public static Map<String, String> guest_success(String webinar_id, String email, String name, String type) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		param.put("webinar_id", webinar_id);
		param.put("email", email);
		param.put("name", name);
		if(type != null){
			param.put("type", type);
		}
		
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(guestUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("guest_success statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}
	
	
	
	
	public static Map<String, String> reportTrack_success(String webinar_id, String pos, String limit) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		if(pos != null){
			param.put("pos", pos);
		}
		if(limit != null){
			param.put("limit", limit);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(reportTrackUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("reportTrack_success statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}
	
	public static Map<String, String> addWhite_success(String webinar_id, String list) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		if(list != null){
			param.put("list", list);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(addWhiteUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("addWhite_success statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}
	
	public static Map<String, String> addWhite_failCheck(String webinar_id, String list, int assertStatusCode, int assertCode) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		if(list != null){
			param.put("list", list);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(addWhiteUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(assertStatusCode).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("addWhite_failCheck statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(assertCode)));
		return result;
	}
	
	
	public static Map<String, String> getOnlineLimit_success(String webinar_id) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(getOnlineLimitUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("getOnlineLimit_success statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}
	
	public static void getOnlineLimit_failCheck(String webinar_id, int assertStatusCode, int assertCode) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if (webinar_id != null) {
			param.put("webinar_id", webinar_id);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(getOnlineLimitUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(assertStatusCode).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println(obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(assertCode)));

	}
	
	
	public static Map<String, String> guest_failCheck(String webinar_id, String email, String name, String type, int assertStatusCode, int assertCode) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		param.put("webinar_id", webinar_id);
		if(email != null){
			param.put("email", email);
		}
		if(name != null){
			param.put("name", name);
		}
		
		if(type != null){
			param.put("type", type);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(guestUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(assertStatusCode).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("guest_failCheck statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(assertCode)));
		return result;
	}
	
	public static Map<String, String> chatHistory_success(String webinar_id, String pos, String limit) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		if(pos != null){
			param.put("pos", pos);
		}
		if(limit != null){
			param.put("limit", limit);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(chatHistoryUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		System.out.println("chatHistory_success statusCode:" + statusCode);
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("chatHistory_success statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}
	
	public static Map<String, String> chatHistory_failCheck(String webinar_id,  String pos, String limit, int assertStatusCode, int assertCode) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		if(pos != null){
			param.put("pos", pos);
		}
		if(limit != null){
			param.put("limit", limit);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(chatHistoryUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(assertStatusCode).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("chatHistory_failCheck statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(assertCode)));
		return result;
	}
	
	public static Map<String, String> guestCancel_success(String webinar_id, String email) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		if(email != null){
			param.put("email", email);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(guestCancelUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("guestCancel_success statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}
	
	public static Map<String, String> guestCancel_failCheck(String webinar_id,  String email, int assertStatusCode, int assertCode) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		if(email != null){
			param.put("email", email);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(guestCancelUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(assertStatusCode).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("guestCancel_failCheck statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(assertCode)));
		return result;
	}
	
	public static Map<String, String> chatFilter_success(String webinar_id, String email, String name) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		if(email != null){
			param.put("email", email);
		}
		if(name != null){
			param.put("name", name);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(chatFilterUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("chatFilter_success statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}
	
	public static Map<String, String> chatFilter_failCheck(String webinar_id,  String email, String name, int assertStatusCode, int assertCode) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		if(email != null){
			param.put("email", email);
		}
		if(name != null){
			param.put("name", name);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(chatFilterUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(assertStatusCode).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("chatFilter_failCheck statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(assertCode)));
		return result;
	}

	public static Map<String, String> online_success(String webinar_id, String start_time, String end_time) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		if(start_time != null){
			param.put("start_time", start_time);
		}
		if(end_time != null){
			param.put("end_time", end_time);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(onlineUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("online_success statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}
	
	public static Map<String, String> online_failCheck(String webinar_id, String start_time, String end_time, int assertStatusCode, int assertCode) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		if(start_time != null){
			param.put("start_time", start_time);
		}
		if(end_time != null){
			param.put("end_time", end_time);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(onlineUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(assertStatusCode).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("online_failCheck statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(assertCode)));
		return result;
	}
	
	public static Map<String, String> activeimage_success(String webinar_id, String image) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		if(image != null){
			param.put("image", image);
		}
		System.out.println("param:" + param);
//		Map<String, String> result = new HttpUtil().requestByPostMethod(activeimageUrl, param);
		new HttpUtil().upload(activeimageUrl, param);
//		String statusCode = result.get("statusCode");
//		String resultText = result.get("resultText");
//		Assert.assertNotNull(statusCode);
//		Assert.assertNotNull(resultText);
//		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
//		JSONObject obj = JSONObject.parseObject(resultText);
//		System.out.println("activeimage_success statusCode:" + statusCode + " obj:" + obj);
//		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
//		return result;
		return null;
	}
	
	
	public static Map<String, String> attendeeRecords_success(String webinar_id) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if(webinar_id != null){
			param.put("webinar_id", webinar_id);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(attendeeRecordsUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println("attendeeRecords_success statusCode:" + statusCode + " obj:" + obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}
	
	public static void attendeeRecords_failCheck(String webinar_id, int assertStatusCode, int assertCode) {
		Map<String, String> param = new HashMap<String, String>();
		Account.setAccount(param);
		if (webinar_id != null) {
			param.put("webinar_id", webinar_id);
		}
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(attendeeRecordsUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(assertStatusCode).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		System.out.println(obj);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(assertCode)));

	}
	
	
	public static Map<String, String> createUser(String subject, String start_time, String exist_3rd_auth,
			String auth_url, String failure_url, String introduction, String layout, String type, String auto_record,
			String is_chat, String host, String buffer) {
		Map<String, String> param = new HashMap<String, String>();
		param.put("subject", subject);
		param.put("start_time", start_time);
		param.put("exist_3rd_auth", exist_3rd_auth);
		param.put("auth_url", auth_url);
		param.put("failure_url", failure_url);
		param.put("introduction", introduction);
		param.put("layout", layout);
		param.put("type", type);
		param.put("auto_record", auto_record);
		param.put("is_chat", is_chat);
		param.put("host", host);
		param.put("buffer", buffer);
		Account.setAccount(param);
		System.out.println("param:" + param);
		Map<String, String> result = new HttpUtil().requestByPostMethod(createUrl, param);
		String statusCode = result.get("statusCode");
		String resultText = result.get("resultText");
		System.out.println("statusCode:" + statusCode);
		System.out.println("resultText:" + resultText);
		Assert.assertNotNull(statusCode);
		Assert.assertNotNull(resultText);
		Assert.assertTrue(String.valueOf(ICode.statusCodeSuccess).equals(statusCode));
		JSONObject obj = JSONObject.parseObject(resultText);
		Assert.assertTrue(obj.getString("code").equals(String.valueOf(ICode.codeSuccess)));
		return result;
	}
	
	
	public static void main(String[] args) {
		Webinar.list_success("1", "0", "1000", null);
	}
	
	
	
}

